package com.cn.hjsj.appInterface.appImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.cn.hjsj.appInterface.appService.AppFigurephotoService;
import com.cn.hjsj.pojo.Figurephoto;
import com.cn.hjsj.service.IFigurephotoService;
import com.cn.hjsj.util.log.LogUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Component("appFigurephotoService")
public class AppFigurephotoImpl implements AppFigurephotoService {
	@Resource(name="figurephotoService")
	private IFigurephotoService figurephotoService;
	@Override
	public Map<String, Object> repair_carousel(JSONObject object) {
		// TODO Auto-generated method stub
		JSONArray carousel = new JSONArray();
		Map<String, Object>  map=new HashMap<String,Object>()
				, mapOne=new HashMap<String,Object>(), maps=new HashMap<String,Object>()
						, mapTwo=new HashMap<String,Object>();
		try{
			 List<Figurephoto>  carouselList = figurephotoService.getList(maps);
			 int count = figurephotoService.getCount(maps);
			 if(count!=0){
				 for (int i=0;i<carouselList.size();i++)
	            {
	                mapOne.put("url", carouselList.get(i).getUrl());
	                carousel.add(mapOne);		              
	            }
				 	mapTwo.put("figurePhoto",carousel);
		            mapTwo.put("count",count);
		            map.put("data", mapTwo);
		            map.put("code", "10000");
		            map.put("mes", "请求成功！");
			 }
			 return map;
		}catch(Exception e){
			LogUtil.error("/AppFigurephotoImpl/repair_carousel:解析参数异常！"+e.getMessage());
			map.put("code", "30000");
			map.put("mes", "参数列表初始化错误，可能不是合法的JSON数据格式！");
			return map;
		}
	}

}
